{
 "metadata": {
  "name": "",
  "signature": "sha256:ef6324d881ad2642060c33707cf6664830560b71d434755dfb56cdd95134cf39"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import os\n",
      "os.chdir(os.path.dirname(os.getcwd()))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from skmultilearn.dataset import Dataset\n",
      "from skmultilearn.lazy.brknn import BinaryRelevanceKNN\n",
      "skml_train = Dataset.load_dataset_dump(\"skmultilearn/data/scene-train.dump.bz2\")\n",
      "skml_test = Dataset.load_dataset_dump(\"skmultilearn/data/scene-test.dump.bz2\")\n",
      "skml_brknna = BinaryRelevanceKNN(extension=BinaryRelevanceKNN.EXTENSION_A)\n",
      "skml_brknna.fit(skml_train['X'], skml_train['y'])\n",
      "skml_brknna_predictions = skml_brknna.predict(skml_test['X'])\n",
      "skml_brknnb = BinaryRelevanceKNN(extension=BinaryRelevanceKNN.EXTENSION_B)\n",
      "skml_brknnb.fit(skml_train['X'], skml_train['y'])\n",
      "skml_brknnb_predictions = skml_brknnb.predict(skml_test['X'])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "import sklearn.metrics\n",
      "print(\"### Predictions equality ###\")\n",
      "print(np.array_equal(skml_brknna_predictions, skml_brknnb_predictions))\n",
      "print(\"### Hamming loss ###\")\n",
      "print(\"BRkNNa: %f\" % sklearn.metrics.hamming_loss(skml_test['y'], skml_brknna_predictions))\n",
      "print(\"BRkNNb: %f\" % sklearn.metrics.hamming_loss(skml_test['y'], skml_brknnb_predictions))\n",
      "print(\"### Accuracy score ###\")\n",
      "print(\"BRkNNa: %f\" % sklearn.metrics.accuracy_score(skml_test['y'], skml_brknna_predictions))\n",
      "print(\"BRkNNb: %f\" % sklearn.metrics.accuracy_score(skml_test['y'], skml_brknnb_predictions))\n",
      "print(\"### F1 score ###\")\n",
      "print(\"BRkNNa: %f\" % sklearn.metrics.f1_score(skml_test['y'], skml_brknna_predictions))\n",
      "print(\"BRkNNb: %f\" % sklearn.metrics.f1_score(skml_test['y'], skml_brknnb_predictions))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "### Predictions equality ###\n",
        "False\n",
        "### Hamming loss ###\n",
        "BRkNNa: 0.103400\n",
        "BRkNNb: 0.102425\n",
        "### Accuracy score ###\n",
        "BRkNNa: 0.590301\n",
        "BRkNNb: 0.658863\n",
        "### F1 score ###\n",
        "BRkNNa: 0.689680\n",
        "BRkNNb: 0.705951\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}